2 ROS2 Nodes

  • Install the turtlesim package for your ROS 2 distro
sudo apt update && sudo apt install ros-$ROS_DISTRO-turtlesim -y
  • Check turtlesim installation:
ros2 pkg executables turtlesim
  • To start turtlesim, enter the following command in your terminal:
ros2 run turtlesim turtlesim_node
  • Open a new terminal (Ctr + Alt + T).
  • Now you will run a new node to control the turtle in the first node:
ros2 run turtlesim turtle_teleop_key
  • You can see the nodes, and their associated topics, services, and actions, using the list subcommands of the respective commands:
  • try these:
ros2 node list
ros2 topic list
ros2 service list
ros2 action list

ROS Qt-based Graphical User Interface Tool (RQT)

  • install RQT
sudo apt update && sudo apt install ros-$ROS_DISTRO-rqt* -y
  • Open a new terminal (Ctr + Alt + T).
rqt

Pasted image 20250929113745.png

Pasted image 20250929113757.png

  • /SPAWN
    Pasted image 20250929113804.png

  • /SET_PEN
    Pasted image 20250929113906.png

Remapping

  • To run two turtlebots with teloop key. In a new terminal, source ROS 2, and run:
ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel

Understanding nodes

Nodes-TopicandService.gif

ROS2 RUN

  • The command ros2 run launches an executable from a package.
  • ros2 run <package_name> <executable_name>
  • To run turtlesim, open a new terminal, and enter the following command:
ros2 run turtlesim turtlesim_node

ros2 node list

  • Open a new terminal while turtlesim is still running in the other one, and enter the following command:
ros2 node list
  • You will see /turtlesim

  • Open another new terminal and start the teleop node with the command:

ros2 run turtlesim turtle_teleop_key
  • Now, let’s reassign the name of our /turtlesim node. In a new terminal, run the following command:
ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle

ros2 node info

  • Now that you know the names of your nodes, you can access more information about them with: ros2 node info <node_name>
ros2 node info /my_turtle

Pasted image 20250929114729.png